package kr.co.casually.adapter;

import java.util.ArrayList;

import kr.co.casually.R;
import kr.co.casually.types.KeyWord;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
public class KeyWordAdapter extends BaseAdapter{
	private Context mContext;
	private ArrayList<KeyWord> mArrayList;
	
	
	
	public KeyWordAdapter(Context context, ArrayList<KeyWord> arrayList) {
		this.mContext = context;
		this.mArrayList = arrayList;
		
		
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mArrayList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mArrayList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return mArrayList.get(position).getId();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		KeyWord keyWord = mArrayList.get(position);
		if (convertView == null) {
			LayoutInflater mInflater = LayoutInflater.from(mContext);
			convertView = mInflater.inflate(R.layout.keyword_list_row, null);
		}
		
		if (keyWord != null) {
			TextView tvGenre = (TextView) convertView
					.findViewById(R.id.keyword_list_genre_tv);
			
			TextView tvTitle = (TextView) convertView
					.findViewById(R.id.keyword_list_title_tv);
			TextView tvStartDAte = (TextView) convertView
					.findViewById(R.id.keyword_list_start_date);
			TextView tvEndDate= (TextView) convertView
					.findViewById(R.id.keyword_list_end_date);
			tvGenre.setText(keyWord.getGenreName());
			tvTitle.setText(keyWord.getTitle());
			tvStartDAte.setText(keyWord.getStartDate());
			tvEndDate.setText(keyWord.getEndDate());
		}
		return convertView;
	}
	

}
